Skip to content

loongarch: Add basic support for LoongArch32 #1837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heiher
Copy link
Contributor

@heiher heiher commented Jun 28, 2025

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Jun 28, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Comment on lines +238 to +244
/// Calculate the approximate double-precision result of dividing 1.0 by the square root
#[inline]
#[target_feature(enable = "frecipe")]
#[unstable(feature = "stdarch_loongarch", issue = "117427")]
pub unsafe fn frsqrte_d(a: f64) -> f64 {
__frsqrte_d(a)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like llvm will just optimize this (no target feature is even needed): https://godbolt.org/z/5s6hvKE51.

Overall we prefer to have fewer (manual) extern "unadjusted¨ items. Also you should probably add some tests that these instructions actually produce the instructions you expect, like so

#[cfg_attr(all(test, target_feature = "frecipe"), assert_instr(frsqrt.d))]

assuming that frecipe is enabled on CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like llvm will just optimize this (no target feature is even needed): https://godbolt.org/z/5s6hvKE51.

They're different -- frsqrte_d_manual generates frsqrt.d, not frsqrt**e**.d.

Overall we prefer to have fewer (manual) extern "unadjusted¨ items. Also you should probably add some tests that these instructions actually produce the instructions you expect, like so

#[cfg_attr(all(test, target_feature = "frecipe"), assert_instr(frsqrt.d))]

assuming that frecipe is enabled on CI.

Sure, I'll add more test cases. Perhaps in a separate PR to keep things focused. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, my bad. so the "e" is for "estimate" apparently. Maybe use that word? (most functions on floats approximate the answer, but apparently this intrinsic deliberately uses less precision to achieve higher speed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants